1. Field of the Invention
The present invention generally relates to a timer, more particularly, to a differentiated granularity timer apparatus and the method thereof.
2. Description of the Prior Art
The timer plays an important role in many digital logical circuits for network application. Especially, for controlling the time needed to store the information in a network system, timer is an indispensable component in so-called garbage collection. for example, in the OSI Standard, the record tables, such as the Forwarding Table of the Layer 2, the routing Table of the Layer 3, and the NAPT Table of the Layer 4, all have to use timer mechanism in order to enable the ASIC to age out the expired information. In the conventional art, a time value T is written into a buffer or a memory. The timing operation performed by the timer is to execute a counting process in every U second(s) (assuming the timer is designed to perform timing operation with the timing granularity of U seconds).
When a timer performs a timing operation from 0 second to T second(s) or in a reverse manner from T second(s) to 0 second, a timeout operation will be triggered. In such case, the larger the time value T is needed, the more space the buffer or the memory must provide. For example, if the timing granularity is one second, the range of the time value is from one second to 24 hours (86,400 seconds), at least 17 bits are required. When many timers operate at the same time, the total memory space required for timing operation will be extremely huge, and the circuit relative to the timing operation will be complex. The difficulties and cost of designing and manufacturing the ASIC will thus be increased.
In the conventional art, the time value T stored in the buffer or the memory is in the form of equal time interval, as described above. For example, if 6 bits are used for storing the time value and the timing granularity is one second, the maximum time value that can be expressed by 6 bits will be 63 seconds (26=64, the 64th second is for timeout).
However, a precise timing mechanism is not always necessary. Sometimes, a small amount of inaccuracy is also acceptable. If a timing mechanism with minor inaccuracy but not with 100% precision is acceptable, there will be a room for improving the conventional timer. The acceptable inaccuracy referred herein is subject to the value and the range of the time value.
Moreover, in many cases of timer designs, since not every timing granularity will be used for timing operation, the timer can be designed to be precise in some specific timing granularities. Even if the time no granularities not being used are with more inaccuracy, the precision and the accuracy of the timer are not affected.